/*
   @Copyright:LeetCode
   @Author:   tjyemail
   @Problem:  http://leetcode.com/problems/two-sum
   @Language: C++
   @Datetime: 19-05-15 09:41
   */

class Solution {
public:
	vector<int> twoSum(vector<int>& nums, int target) {
		unordered_map<int,int> dict;    // num, index
		for(int i=nums.size(); i--; dict[nums[i]]=i)
			if(dict.count(target-nums[i]))
				return {i,dict[target-nums[i]]};
		return {};
	}
};
